package nccloud.web.arap.manual.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.map.HashedMap;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import nc.itf.org.IAccountingBookQryService;
import nc.itf.pubapp.pub.smart.IBillQueryService;
import nc.vo.org.AccountingBookVO;
import nc.vo.pub.BusinessException;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.itf.arap.manual.aggmanualcostvo.IManualcostvoService;

public class CreateVoucherAction implements ICommonAction {

	@Override
	public Object doAction(IRequest request) { 
		String json = request.read();
		JsonParser parser = new JsonParser();
		JsonObject param = parser.parse(json).getAsJsonObject();
		String pk = param.get("pk").getAsString();
		String ts = param.get("ts").getAsString();
		String action = param.get("action").getAsString();
		Map<String,String> result = new HashMap<String,String>();
	 
		try {
			if("Voucher".equals(action)) {
				ServiceLocator.find(IManualcostvoService.class).createVoucherAction(pk,ts);
			}else {
				ServiceLocator.find(IManualcostvoService.class).redHandleAction(pk,ts);
			}
			
			result.put("isSuccess", "Y");
		} catch (BusinessException e) {
			result.put("isSuccess", "N");
			result.put("errorMessage", e.getMessage());
		}
		 
		return result;
		 
	}

}
